<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../base.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 页面meta /-->
</head>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <section class="content-header">
        <h1>
            统计分析
            <small>ip登陆次数排行</small>
        </h1>
    </section>
    <section class="content">
        <div class="box box-primary">
            <div id="main" style="width: 900px;height:500px;"></div>
        </div>
    </section>
</div>
</body>
<script src="../plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="../../plugins/echarts/echarts.min.js"></script>
<script type="text/javascript">

    $.get("/stat/findIpData.do",function (data) {
        var username = [];
        var ip = [];
        for (var i=0; i<data.length; i++){
            var obj = data[i];
            username[i] = obj.username;
            ip[i] = obj.ip;
        }
    //1.初始化echarts实例(定义图形展示的位置)
     var myChart = echarts.init(document.getElementById('main'));
    // option = {
    //     xAxis: {
    //         type: 'category',
    //         data: username,
    //         axisLabel: {
    //             rotate:30
    //         }
    //     },
    //     yAxis: {
    //         type: 'value'
    //     },
    //     series: [{
    //         data: ip,
    //         type: 'bar',
    //         showBackground: true,
    //         backgroundStyle: {
    //             color: 'rgba(220, 220, 220, 0.8)'
    //         }
    //     }]
    // };


        option = {
            tooltip: {
                trigger: 'axis',
                axisPointer: {            // 坐标轴指示器，坐标轴触发有效
                    type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: {
                type: 'value'
            },
            yAxis: {
                type: 'category',
                data: username
            },
            series: [
                {
                    type: 'bar',
                    label: {
                        show: true,
                        position: 'insideRight'
                    },
                    data: ip
                }
            ]
        };
    //3.使用配置生成图形
    myChart.setOption(option);
    })

</script>

</html>